package com.zxn.tablayoutsamples.ui

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.zxn.tablayoutsamples.adapter.SimpleHomeAdapter
import android.widget.AdapterView.OnItemClickListener
import android.widget.AdapterView
import android.content.Intent
import android.graphics.Color
import android.view.View
import android.widget.ListView

/**
 * 标签列表页面.
 */
class SimpleHomeActivity : AppCompatActivity() {
    private val mItems = arrayOf(
        "LottieTabLayout",
        "ProminentTabLayout",
        "SlidingTabLayout",
        "CommonTabLayout",
        "SegmentTabLayout",
        "ShadowTabLayout",
        "SingleShadowTabActivity",
        "SlidingScaleTabLayout(new)",
        "SlidingScaleTabLayoutFragmentActivity(new)",
        "SlidingScaleTabLayoutFragmentActivity(2)"
    )
    private val mClasses = arrayOf<Class<*>>(
        LottieTabLayoutActivity::class.java,
        ProminentTabActivity::class.java,
        SlidingTabActivity::class.java,
        CommonTabActivity::class.java,
        SegmentTabActivity::class.java,
        ShadowTabActivity::class.java,
        SingleShadowTabActivity::class.java,
        SlidingScaleTabLayoutActivity::class.java,
        SlidingScaleTabLayoutFragmentActivity::class.java,
        SlidingScaleTabLayoutActivity2::class.java
    )
    private val mContext: Context = this
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val lv = ListView(mContext)
        lv.cacheColorHint = Color.TRANSPARENT
        lv.setFadingEdgeLength(0)
        lv.adapter = SimpleHomeAdapter(mContext, mItems)
        lv.onItemClickListener =
            OnItemClickListener { parent: AdapterView<*>?, view: View?, position: Int, id: Long ->
                val intent = Intent(mContext, mClasses[position])
                startActivity(intent)
            }
        setContentView(lv)
    }
}